<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Jetson Inference: Mutex Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="NVLogo_2D.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Jetson Inference
   </div>
   <div id="projectbrief">DNN Vision Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('classMutex.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-attribs">Protected Attributes</a> &#124;
<a href="classMutex-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Mutex Class Reference<div class="ingroups"><a class="el" href="group__util.html">Utilities Library (jetson-utils)</a> &raquo; <a class="el" href="group__threads.html">Multithreading</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>A lightweight mutual exclusion lock.  
 <a href="classMutex.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="Mutex_8h_source.html">Mutex.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a593423d868daf926c7b0d63a833ae29a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#a593423d868daf926c7b0d63a833ae29a">Mutex</a> ()</td></tr>
<tr class="memdesc:a593423d868daf926c7b0d63a833ae29a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor.  <a href="#a593423d868daf926c7b0d63a833ae29a">More...</a><br /></td></tr>
<tr class="separator:a593423d868daf926c7b0d63a833ae29a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac9e9182407f5f74892318607888e9be4"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#ac9e9182407f5f74892318607888e9be4">~Mutex</a> ()</td></tr>
<tr class="memdesc:ac9e9182407f5f74892318607888e9be4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor.  <a href="#ac9e9182407f5f74892318607888e9be4">More...</a><br /></td></tr>
<tr class="separator:ac9e9182407f5f74892318607888e9be4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a87f92bea41231778680c392668b4ad6f"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#a87f92bea41231778680c392668b4ad6f">AttemptLock</a> ()</td></tr>
<tr class="memdesc:a87f92bea41231778680c392668b4ad6f"><td class="mdescLeft">&#160;</td><td class="mdescRight">If the lock is free, aquire it.  <a href="#a87f92bea41231778680c392668b4ad6f">More...</a><br /></td></tr>
<tr class="separator:a87f92bea41231778680c392668b4ad6f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae5cb54c9c45f90e29206d5679a3b1c7f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#ae5cb54c9c45f90e29206d5679a3b1c7f">Lock</a> ()</td></tr>
<tr class="memdesc:ae5cb54c9c45f90e29206d5679a3b1c7f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Aquire the lock, whenever it becomes available.  <a href="#ae5cb54c9c45f90e29206d5679a3b1c7f">More...</a><br /></td></tr>
<tr class="separator:ae5cb54c9c45f90e29206d5679a3b1c7f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad5de61abafec4bbec4cd7e796e5209fd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#ad5de61abafec4bbec4cd7e796e5209fd">Unlock</a> ()</td></tr>
<tr class="memdesc:ad5de61abafec4bbec4cd7e796e5209fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release the lock.  <a href="#ad5de61abafec4bbec4cd7e796e5209fd">More...</a><br /></td></tr>
<tr class="separator:ad5de61abafec4bbec4cd7e796e5209fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5fce312e70fb4d09af9436d4e5912f7e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#a5fce312e70fb4d09af9436d4e5912f7e">Sync</a> ()</td></tr>
<tr class="memdesc:a5fce312e70fb4d09af9436d4e5912f7e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Wait for the lock, then release it immediately.  <a href="#a5fce312e70fb4d09af9436d4e5912f7e">More...</a><br /></td></tr>
<tr class="separator:a5fce312e70fb4d09af9436d4e5912f7e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7d62eeb42273e4f4946ebf8a757db4c9"><td class="memItemLeft" align="right" valign="top">pthread_mutex_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#a7d62eeb42273e4f4946ebf8a757db4c9">GetID</a> ()</td></tr>
<tr class="memdesc:a7d62eeb42273e4f4946ebf8a757db4c9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the mutex object.  <a href="#a7d62eeb42273e4f4946ebf8a757db4c9">More...</a><br /></td></tr>
<tr class="separator:a7d62eeb42273e4f4946ebf8a757db4c9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr class="memitem:a8fc19c03aa404e9efddc2c91132ebd02"><td class="memItemLeft" align="right" valign="top">pthread_mutex_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMutex.html#a8fc19c03aa404e9efddc2c91132ebd02">mID</a></td></tr>
<tr class="separator:a8fc19c03aa404e9efddc2c91132ebd02"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A lightweight mutual exclusion lock. </p>
<p>It is very fast to check if the mutex is available, lock it, and release it. However, if the mutex is unavailable when you attempt to lock it, execution of the thread will stop until it becomes available. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a593423d868daf926c7b0d63a833ae29a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a593423d868daf926c7b0d63a833ae29a">&#9670;&nbsp;</a></span>Mutex()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Mutex::Mutex </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor. </p>

</div>
</div>
<a id="ac9e9182407f5f74892318607888e9be4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac9e9182407f5f74892318607888e9be4">&#9670;&nbsp;</a></span>~Mutex()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Mutex::~Mutex </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Destructor. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a87f92bea41231778680c392668b4ad6f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a87f92bea41231778680c392668b4ad6f">&#9670;&nbsp;</a></span>AttemptLock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Mutex::AttemptLock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>If the lock is free, aquire it. </p>
<p>Otherwise, return without waiting for it to become available. </p><dl class="section return"><dt>Returns</dt><dd>True if the lock was aquired, false if not. </dd></dl>

</div>
</div>
<a id="a7d62eeb42273e4f4946ebf8a757db4c9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7d62eeb42273e4f4946ebf8a757db4c9">&#9670;&nbsp;</a></span>GetID()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">pthread_mutex_t* Mutex::GetID </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Get the mutex object. </p>

</div>
</div>
<a id="ae5cb54c9c45f90e29206d5679a3b1c7f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae5cb54c9c45f90e29206d5679a3b1c7f">&#9670;&nbsp;</a></span>Lock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Mutex::Lock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Aquire the lock, whenever it becomes available. </p>
<p>This could mean just a few instructions if the lock is already free, or to block the thread if it isn't. </p>

</div>
</div>
<a id="a5fce312e70fb4d09af9436d4e5912f7e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5fce312e70fb4d09af9436d4e5912f7e">&#9670;&nbsp;</a></span>Sync()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Mutex::Sync </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Wait for the lock, then release it immediately. </p>
<p>Use this in situations where you are waiting for an event to occur. </p>

</div>
</div>
<a id="ad5de61abafec4bbec4cd7e796e5209fd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad5de61abafec4bbec4cd7e796e5209fd">&#9670;&nbsp;</a></span>Unlock()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Mutex::Unlock </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Release the lock. </p>

</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a8fc19c03aa404e9efddc2c91132ebd02"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8fc19c03aa404e9efddc2c91132ebd02">&#9670;&nbsp;</a></span>mID</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">pthread_mutex_t Mutex::mID</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>jetson-utils/<a class="el" href="Mutex_8h_source.html">Mutex.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="classMutex.html">Mutex</a></li>
    <li class="footer">Generated on Thu Sep 26 2019 12:19:12 for Jetson Inference by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
